/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import org.json.JSONObject;

/**
 *
 * @author banhbaochay
 */
public class SharedObject {

    /**
     * Key to store browser object in sharedobject
     */
    public static final String BROWSER = "browser";
    
    /**
     * Key to store consumer key object in sharedobject
     */
    public static final String CONSUMER_KEY = "oauth.consumer.key";
    
    /**
     * Key to store consumer secret object in sharedobject
     */
    public static final String CONSUMER_SECRET = "oauth.consumer.secret";
    
    /**
     * Key to store path object in sharedobject
     */
    public static final String PATH = "path";
    
    /**
     * Key to store album map object in sharedobject
     */
    public static final String ALBUM_MAP = "album.map";
    
    /**
     * Key to store user json object in sharedobject
     */
    public static final String USER_JSON = "user.json";
    
    /**
     * Key to get error not defined message
     */
    public static final String ERROR_NOT_DEFINED = "error-not-defined";
    
    /**
     * 
     * @param browser
     * @param oauthConsumerKey
     * @param oauthConsumerSecret
     * @param locale  
     */
    public SharedObject(Browser browser, String oauthConsumerKey,
            String oauthConsumerSecret) {
        sharedMap = new HashMap();
        sharedMap.put(BROWSER, browser);
        sharedMap.put(CONSUMER_KEY, oauthConsumerKey);
        sharedMap.put(CONSUMER_SECRET, oauthConsumerSecret);
    }
    
    
    /**
     * add path to share
     * @param path path for open file
     */
    public void addPath(String path) {
        sharedMap.put(PATH, path);
    }// end addAlbumMap method
    
    /**
     * Get path. 
     * Should cast object to String
     * @return String type
     */
    public Object getPath() {
        return sharedMap.get(PATH);
    }// end addAlbumMap method
    
    /**
     * add album map to share
     * @param albumMap 
     */
    public void addAlbumMap(Map albumMap) {
        sharedMap.put(ALBUM_MAP, albumMap);
    }// end addAlbumMap method
    
    /**
     * You should cast to Browser type
     * @return Browser type
     */
    public Object getBrowser() {
        return sharedMap.get(BROWSER);
    }// end getBrowser method
    
    /**
     * You should cast to String type
     * @return String type
     */
    public Object getOauthConsumerKey() {
        return sharedMap.get(CONSUMER_KEY);
    }// end getBrowser method
    
    /**
     * You should cast to String type
     * @return String type
     */
    public Object getOauthConsumerSecret() {
        return sharedMap.get(CONSUMER_SECRET);
    }// end getBrowser method
    
    /**
     * add user json to share
     * @param userJSON json receive from access method
     */
    public void addUserJSON(JSONObject userJSON) {
        sharedMap.put(USER_JSON, userJSON);
    }// end addUserJSON method
    
    /**
     * You should cast object to Map type
     * @return Map&lt;String, Album&gt; type
     */
    public Object getAlbumMap() {
        return sharedMap.get(ALBUM_MAP);
    }// end getAlbumMap method
    
    /**
     * You should cast object to JSONObject type
     * @return JSONObject type
     */
    public Object getUserJSON() {
        return sharedMap.get(USER_JSON);
    }// end getUserJSON method
    
    /**
     * Returns <tt>true</tt> if this map contains a mapping for the specified
     * key.  More formally, returns <tt>true</tt> if and only if
     * this map contains a mapping for a key <tt>k</tt> such that
     * <tt>(key==null ? k==null : key.equals(k))</tt>.  (There can be
     * at most one such mapping.)
     * @param key
     * @return <tt>true</tt> if this map contains a mapping for the specified
     *         key
     */
    public boolean containsKey(Object key) {
        return sharedMap.containsKey(key);
    }// end contains method
    
    /**
     * Returns <tt>true</tt> if this map maps one or more keys to the
     * specified value.  More formally, returns <tt>true</tt> if and only if
     * this map contains at least one mapping to a value <tt>v</tt> such that
     * <tt>(value==null ? v==null : value.equals(v))</tt>.  This operation
     * will probably require time linear in the map size for most
     * implementations of the <tt>Map</tt> interface.
     * @param value
     * @return true if this map maps one or more keys to the specified value
     */
    public boolean containsValue(Object value) {
        return sharedMap.containsValue(value);
    }// end containsValue method
    
    private Map sharedMap;
}// end SharedObject class

